<?php
declare(strict_types=1);
namespace App\Controller\Cash\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Service\UserService\CashManagerService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Middleware;
use App\Middleware\CashMiddleware;

/**
 * 收银员控制器
 * @author Luoshumai
 * @Controller(prefix="/cash/v1/manager")
 * @Middleware(CashMiddleware::class)
 */
class CashManagerController extends AbstractController
{
    /**
     * @Inject
     * @var CashManagerService
     */
    protected $cashManagerService;

    /**
     * 获取收银员接口
     * @RequestMapping(path="getlist", methods="post")
     */
    public function getCashManagerList(RequestInterface $request)
    {
        return $this->cashManagerService->getCashUsers($request->getAttribute('cid'),$request->getAttribute('mn_sid'));
    }

    /**
     * 修改收银员密码接口
     * @RequestMapping(path="editpass", methods="post")
     */
    public function editPassword(RequestInterface $request)
    {
        return $this->cashManagerService->editPassword($request->getAttribute('manager_id'),$request->getParsedBody());
    }
    
    /**
     * 修改收银员昵称接口
     * @RequestMapping(path="editname", methods="post")
     */
    public function editName(RequestInterface $request)
    {
        return $this->cashManagerService->editName($request->getAttribute('manager_id'),$request->getParsedBody());
    }
}